import { postUrl, getUrl, patchUrl, deleteUrl } from '../utils/http';
//登录
export const login = (params) => {
    return postUrl('/user/login', params)
}
//租房小组 
export const groups = (params) => {
    return getUrl('/home/groups', params)
}

//租房小组 
export const news = (params) => {
    return getUrl('/home/news', params)
}

//获取城市列表 
export const areaCity = (params) => {
    return getUrl('/area/city', params)
}

//热门城市 
export const areaHot = (params) => {
    return getUrl('/area/hot', params)
}

//根据城市名查询该城市信息
export const areaInfo = (params) => {
    return getUrl('/area/info', params)
}

//获取用户信息 
export const getUser = () => {
    return getUrl('/user')
}

//获取房屋查询条件 /houses
export const getHouses = (params) => {
    return getUrl('/houses/condition', params)
}

//根据条件查询房屋
export const getHousesList = (params) => {
    console.log(params);
    return getUrl('/houses', params)
}

//根据条件查询房屋 /area/map
export const getHousesDetail = (params) => {
    return getUrl(`/houses/${params.id}`)
}

//百度地图 
export const getmap = (params) => {
    return getUrl(`/area/map`, params)
}

// 获取发布房源的信息 
export const getparams = () => {
    return getUrl(`/houses/params`)
}

// 上传图片 
export const getimg = (params) => {
    return postUrl(`/houses/image`, params)
}

//发布房源
export const postHouses = (params) => {
    console.log(params);
    return postUrl(`/user/houses`, params)
}

// 查看已发布房源 
export const getUserHouses = () => {
    return getUrl(`/user/houses`)
}

export const patchHouses = (params) => {
    return patchUrl(`/user/houses/${params.id}`, params.shelf)
}

// 更改用户信息
export const setUser = (params) => {
    return patchUrl(`/user`, params)
}
//获取收藏
export const getFavorites = () => {
    return getUrl(`/user/favorites`,)
}

// 删除收藏 
export const delFavorites = (params) => {
    return deleteUrl(`/user/favorites/${params}`)
}

//查看收藏
//添加
export const addFavorites = (data) => {
    console.log(data);
    return postUrl("/user/favorites/" + data.id);
}

//获取是否收藏
export const getIsFavorites = (data) => {
    return getUrl(`/user/favorites${data.id ? "/" + data.id : ""}`);
}
